{% extends 'layout.html' %}

{% block title %}
    <title>部门主页</title>
{% endblock %}

{% block content %}
    <a href="{% url 'dept_add' %}">
        <button class=" btn btn-primary btn-sm" style="margin-bottom: 10px">新增</button>
    </a>

    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">部门列表</div>
        <!-- Table -->
        <table class="table table-hover table-bordered">
            <tr>
                <th>序号</th>
                <th>部门名</th>
                <th>部门地址</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            {% for department in departments %}
                <tr>
                    <td>{{ forloop.counter }}</td>
                    <td>{{ department.name }}</td>
                    <td>{{ department.address }}</td>
                    <td>{{ department.create_date }}</td>
                    <td>
                        <a href="{% url 'dept_edit' department.id %}">
                            <button class=" btn btn-primary btn-sm">编辑</button>
                        </a>
                        <a href="{% url 'dept_delete' department.id %}">
                            <button class=" btn btn-danger btn-sm">删除</button>
                        </a>
                    </td>
                </tr>

            {% endfor %}

        </table>
    </div>
{% endblock %}